<template>
  <div class="admin-dashboard">
    <header class="dashboard-header">
      <h1>管理员仪表板</h1>
      <div class="user-info">
        <span>欢迎, {{ user.username }}! ({{ user.role }})</span>
        <button @click="logout" class="logout-btn">登出</button>
      </div>
    </header>
    
    <main class="dashboard-content">
      <div class="info-card">
        <h2>管理员信息</h2>
        <p><strong>用户名:</strong> {{ user.username }}</p>
        <p><strong>角色:</strong> {{ user.role }}</p>
      </div>
      
      <div class="info-card">
        <h2>管理功能</h2>
        <button class="action-btn">用户管理</button>
        <button class="action-btn">技师管理</button>
        <button class="action-btn">订单管理</button>
        <button class="action-btn">车辆管理</button>
        <button class="action-btn">材料管理</button>
        <button class="action-btn">反馈管理</button>
      </div>
      
      <div class="info-card">
        <h2>数据统计</h2>
        <button class="action-btn">维修统计</button>
        <button class="action-btn">成本分析</button>
        <button class="action-btn">技师绩效</button>
        <button class="action-btn">用户反馈</button>
      </div>
    </main>
  </div>
</template>

<script>
export default {
  name: 'AdminDashboard',
  data() {
    return {
      user: {}
    }
  },
  created() {
    this.loadUserInfo();
  },
  methods: {
    loadUserInfo() {
      const userData = localStorage.getItem('user');
      if (userData) {
        this.user = JSON.parse(userData);
      }
    },
    logout() {
      localStorage.removeItem('user');
      localStorage.removeItem('userRole');
      this.$router.push('/');
    }
  }
}
</script>

<style scoped>
.admin-dashboard {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
  padding: 20px;
  background-color: #f8f9fa;
  border-radius: 8px;
}

.dashboard-header h1 {
  color: #333;
  margin: 0;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 15px;
}

.logout-btn {
  padding: 8px 16px;
  background-color: #dc3545;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.3s;
}

.logout-btn:hover {
  background-color: #c82333;
}

.dashboard-content {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
}

.info-card {
  background-color: white;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.info-card h2 {
  color: #333;
  margin-bottom: 15px;
  border-bottom: 2px solid #17a2b8;
  padding-bottom: 5px;
}

.info-card p {
  margin: 10px 0;
  color: #666;
}

.action-btn {
  display: block;
  width: 100%;
  margin: 10px 0;
  padding: 12px;
  background-color: #17a2b8;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.3s;
}

.action-btn:hover {
  background-color: #138496;
}
</style>